package com.yilu.driver.base;

import android.os.Bundle;
import android.widget.Toast;

import com.is.ui.base.BaseAppCompatActivity;
import com.is.ui.eventbus.EventCenter;
import com.is.ui.netstatus.NetUtils;
import com.is.ui.widget.ProgressDialog;

/**
 * Created by John on 2017/4/13.
 */
public abstract class BaseActivity extends BaseAppCompatActivity {

    /**
     * 弹出加载框
     *
     * @param msg
     */
    @Override
    public void showLoading(String msg) {
        ProgressDialog.showDialogForLoading(mContext, msg, true);
    }

    /**
     * 影藏加载框
     */
    @Override
    public void hideLoading() {
        ProgressDialog.cancelDialogForLoading();
    }

    /**
     * 错误提示
     *
     * @param msg
     */
    @Override
    public void showError(String msg) {
        Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show();
    }

    /**
     * 异常提示
     *
     * @param msg
     */
    @Override
    public void showException(String msg) {
        Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show();
    }

    /**
     * 消息提示 Toast
     *
     * @param msg
     */
    @Override
    public void showToast(String msg) {
        Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show();
    }

    /**
     * get bundle data
     * 获取绑定数据
     *
     * @param extras
     */
    @Override
    protected void getBundleExtras(Bundle extras) {

    }

    /**
     * when event comming
     * 事件来了
     *
     * @param eventCenter
     */

    @Override
    protected void onEventComming(EventCenter eventCenter) {

    }

    /**
     * network connected
     * 网络连接
     */
    @Override
    protected void onNetworkConnected(NetUtils.NetType type) {
        if (type.name().equals("WIFI")) {
            showToast("已连接" + type.name() + "网络");
        } else if (type.name().equals("CMNET")) {
        } else if (type.name().equals("CMWAP")) {
        } else if (type.name().equals("NONE")) {

        }

    }

    /**
     * network disconnected
     * 网络未连接
     */
    @Override
    protected void onNetworkDisConnected() {
        showToast("网络连接断开");
    }

    /**
     * is applyStatusBarTranslucency
     * 是否应用状态栏透明
     *
     * @return
     */
    @Override
    protected boolean isApplyStatusBarTranslucency() {
        return false;
    }

    /**
     * is bind eventBus
     * 是否绑定事件
     *
     * @return
     */
    @Override
    protected boolean isBindEventBusHere() {
        return false;
    }

    /**
     * toggle overridePendingTransition
     * 是否开启activity动画切换
     *
     * @return
     */
    @Override
    protected boolean toggleOverridePendingTransition() {
        return true;
    }

    /**
     * get the overridePendingTransition mode
     * 设置获取动画模式
     */
    @Override
    protected TransitionMode getOverridePendingTransitionMode() {
        return TransitionMode.LEFT;
    }

    /**
     * 初始化presenter
     */
    @Override
    public void initPresenter() {
        mPresenter.setVM(this, mModel);
    }

    /**
     * 是否设置状态栏颜色
     *
     * @return
     */
    @Override
    protected boolean isApplySystemBarColor() {
        return true;
    }
}
